<?php use \Inationsoft\NS; use \Inationsoft\NS\UI\Widget; ?> 
<div class="breadcrumbwidget">
	<ul class="breadcrumb">
		<li><a href="http://localhost/~inanta/simtur">Beranda</a> <span class="divider">/</span></li>
		<li><a href="<?php echo $app_base_url; ?>">Manajemen Pengguna</a> <span class="divider">/</span></li>
		<li class="active">Tambah</li>
	</ul>
</div><!--breadcrumbs-->
<div class="pagetitle">
	<div class="row-fluid">
		<div class="span6"><h1>Manajemen Pengguna</h1><span>Manajemen Pengguna</span></div>
		<div class="span6">
			<div id="header-button">
				<ul>
					<li><?php echo new Widget\Bootstrap\HyperlinkButton(null, $app_base_url . '/confirmrole', '<span class="icon-ok"></span> Simpan'); ?></li>
				</ul>
			</div>
		</div>
	</div>
</div><!--pagetitle-->

<div class="maincontent">
	<div class="contentinner">
		<div class="form-wrapper">
			<h4 class="widgettitle shadowed">Daftar Keseluruhan Peran Pengguna</h4>
			<div class="widgetcontent">
				<table class="data-list table table-bordered">
					<thead>
						<tr class="table-pre">
							<td colspan="3">
								<form method="post" action="<?php echo $app_base_url; ?>/managerole/<?php echo $user['uid']; ?>">
								<?php echo new Widget\Hidden('token', $token); ?> 
								Tampilkan: <?php echo new Widget\ListBox('page_limit', array('5' => '5', '15' => '15', '100' => '100', '0' => 'Semua'), $page_limit); ?>&nbsp;<?php echo new Widget\ListBox('search_column', array('role' => 'Peran', 'description' => 'Deskripsi')) ?>&nbsp; 
								<?php echo new Widget\Text('search_keyword', $search_keyword) ?>&nbsp;<?php echo new Widget\Bootstrap\Button('dispatch', 'page_limit', Widget\Button::BUTTON_SUBMIT, '<span class="icon-search"></span> Cari'); ?> 
								</form>
							</td>
						</tr>
						<tr>
							<th>Peran</th>
							<th>Deskripsi</th>
							<th class="align-center">Tindakan</th>
						<tr>
					</thead>
					<tbody>
						<?php $counter = 0; ?>
						<?php foreach($datas as $data): ?>
						<?php if($counter % 2 == 0): ?>
						<tr class="alternate-row">
						<?php else: ?>
						<tr>
						<?php endif; ?>
							<td><?php echo $data['role']; ?></td>
							<td><?php echo $data['description']; ?></td>
							<td class="align-center action-button">
								<form method="post" action="<?php echo $app_base_url; ?>/saverole/<?php echo $user['uid']; ?>">
								<?php echo new Widget\Hidden('rid', $data['rid']); ?>
								<?php echo new Widget\Bootstrap\Button('saverole', 'saverole', Widget\Bootstrap\Button::BUTTON_SUBMIT, '<span class="icon-plus"></span> Tambah'); ?>
								</form>
							</td>
						</tr>
						<?php ++$counter; ?>
						<?php endforeach; ?> 
					</tbody>
					<tfoot>
						<tr class="table-pos">
							<td colspan="2">
								<?php echo ($data_count == 0 ? 'Data tidak ditemukan' : ($page_limit == 0 ? sprintf('Menampilan data 1 sampai %s dari total %s data', $data_count, $data_count) : sprintf('Menampilan data %s sampai %s dari total %s data', ((($page * $page_limit) - $page_limit) + 1), (($page * $page_limit) > $data_count ? $data_count : ($page * $page_limit)), $data_count))) ?> 
							</td>
							<td colspan="2" class="align-right">
								<?php echo new Widget\Paginator('pager', $data_count, $page, $page_limit, $app_base_url . '/managerole/' . $user['uid'] . '/' . $page_limit . '/'); ?> 
							</td>
						</tr>
					</tfoot>
				</table>
			</div>

			<h4 class="widgettitle shadowed">Daftar Peran Pengguna Saat Ini</h4>
			<div class="widgetcontent">
				<table class="data-list table table-bordered">
					<thead>
						<tr>
							<th>Peran</th>
							<th>Deskripsi</th>
							<th class="align-center">Tindakan</th>
						<tr>
					</thead>
					<tbody>
						<?php $counter = 0; ?>
						<?php foreach($user['koma_users_roles'] as $data): ?>
						<?php if($counter % 2 == 0): ?>
						<tr class="alternate-row">
						<?php else: ?>
						<tr>
						<?php endif; ?>	
							<td><?php echo $data['role']; ?></td>
							<td><?php echo $data['description']; ?></td>
							<td class="align-center action-button">
								<?php echo new Widget\Bootstrap\HyperlinkButton(null, $app_base_url . '/removerole/' . $user['uid'] . '/' . $data['rid'], '<span class="icon-trash"></span> Hapus'); ?>
							</td>
						</tr>
						<?php ++$counter; ?>
						<?php endforeach; ?> 
					</tbody>
					<tfoot>
						<tr class="table-pos">
							<td colspan="4">
								<?php echo (count($user['koma_users_roles']) == 0 ? 'Belum ada barang yang ditambahkan' : sprintf('Menampilan total %s data', count($user['koma_users_roles']))) ?> 
							</td>
						</tr>
					</tfoot>
				</table>
			</div>
		</div>
	</div><!--contentinner-->
</div><!--maincontent-->